package com.itheima.ListMap;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class DDZhu {
    public static void main(String[] args) {
        HashMap<Integer, String> hm = new HashMap<Integer, String>();
        ArrayList<Integer> al = new ArrayList<Integer>();
        String[] colors = {"♦", "♣", "♥", "♠"};
        String[] numbers = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        int index = 0;
        for (String color : colors) {
            for (String number : numbers) {
                hm.put(index, color + number);
                al.add(index);
                index++;
            }
        }
        hm.put(index, "小王");
        al.add(index);
        index++;
        hm.put(index, "大王");
        al.add(index);
        Collections.shuffle(al);
        TreeSet<Integer> t1 = new TreeSet<Integer>();
        TreeSet<Integer> t2 = new TreeSet<Integer>();
        TreeSet<Integer> t3 = new TreeSet<Integer>();
        TreeSet<Integer> t4 = new TreeSet<Integer>();
        for (int i : al) {
            int x = al.get(i);
            if (i >= al.size() - 3) {
                t1.add(x);
            } else if (i % 3 == 0) {
                t2.add(x);
            } else if (i % 3 == 1) {
                t3.add(x);
            } else if (i % 3 == 2) {
                t4.add(x);
            }
        }
        lookPoker("张三", t2, hm);
        lookPoker("李四", t3, hm);
        lookPoker("王五", t4, hm);
        lookPoker("底牌", t1, hm);


    }

    private static void lookPoker(String name, TreeSet<Integer> t, HashMap<Integer, String> hm) {
        System.out.println(name + "的牌是:");
        for (Integer i : t) {
            String p = hm.get(i);
            System.out.print(p + " ");
        }
        System.out.println("- - - - - - - - - - - - - - - - - - - - - - - - - - ");
    }


}
